import { Controller } from "../../mvc/core/Controller";
import { Cache } from "../cache/Cache";
import { IMountModule } from "../../../modules/interfaces/IMountModule";
import { IView } from "../../mvc/interfaces/IView";
import { MountModule } from "../../../modules/MountModule";
import { WindowEvent } from "../../component/window/WindowEvent";
import { DataEvent } from "../events/DataEvent";
import { RolePlayer } from "../scene/player/entity/RolePlayer";
import { ScreenOperation } from "../scene/ScreenOperation";
import { ItemData } from "../resource/info/ItemData";
import { StatusType } from "../rules/StatusType";
import { MsgManager } from "../manager/MsgManager";
import { Language } from "../../../extend/language/Language";
import { SkillProgress } from "../view/common/SkillProgress";
import { ProcessType } from "../rules/ProcessType";
import { RolePlayerEvent } from "../scene/events/RolePlayerEvent";
import { GameProxy } from "../mvc/GameProxy";
import { Game } from "../Game";
import { Dispatcher } from "../../mvc/core/Dispatcher";
import { EventName } from "../mvc/EventName";
import { NetDispatcher } from "../../mvc/core/NetDispatcher";
import { ServerCommand } from "../mvc/ServerCommand";
import { EPublicCommand } from "../../../Message/Command/EPublicCommand";
import { ECategory } from "../../../Message/Public/ECategory";
import { EProp } from "../../../Message/Public/EProp";
import { MountUtil } from "../scene/mount/MountUtil";
import { MessageBlock } from "../../../Framework/MQ/MessageBlock";
import { SAttribute } from "../../../Message/Public/SAttribute";
import { Alert } from "../../../com/mui/controls/Alert";
import { PulseSharedObject } from "../view/player/PulseSharedObject";
import { MountConfig } from "../resource/MountConfig";
import { CutDataUtil } from "../../common/tools/CutDataUtil";
import { SActiveToClient } from "../../../Message/Public/SActiveToClient";
import { JSONHelper } from "../../../com/mui/serialization/json/JSONHelper";
import { CalcUtil } from "../view/common/util/CalcUtil";
import { SMountWash } from "../../../Message/Game/SMountWash";
import { AutoGuideData } from "../view/common/guide/AutoGuideData";
import { MountChangeModelWindow } from "../view/mounts/panel/MountChangeModelWindow";
import { MountCraveWindow } from "../view/mounts/panel/MountCraveWindow";
import { ItemConfig } from "../resource/ItemConfig";
import { DateParser } from "../../common/tools/DateParser";
import { ClockManager } from "../manager/ClockManager";
import { CheckBoxWin } from "../view/common/alertwins/CheckBoxWin";
import { EPlayerItemPosType } from "../../../Message/Public/EPlayerItemPosType";
import { Log } from "../../../com/gengine/debug/Log";
import { GameController } from "../mvc/GameController";
type int = number;
//class MountsController
    
    export  class MountsController extends Controller
    {
       

        /* internal  */onBackPackChangeHandler(arg1: Object=null): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            if (this._mountModule && !this._mountModule.isHide) 
            {
                loc1 = Cache.instance.pack.mountsPackCache.getMountArrayFromPack();
                loc2 = Cache.instance.pack.mountsPackCache.getItemMountCanFeed();
                this._mountModule.updateListPanel(loc1);
                this._mountModule.updateItemFeed(loc2);
                this._mountModule.updateReinDrug();
                loc3 = Cache.instance.pack.backPackCache.getAllItems();
                loc4 = [];
                loc5 = 0;
                while (loc5 < loc3.length) 
                {
                    if (loc3[loc5] !== null) 
                    {
                        loc4.push(loc3[loc5]);
                    }
                    ++loc5;
                }
                this._mountModule.updateCostItem(loc4);
            }
            return;
        }

        public get mountModule(): IMountModule
        {
            if (null == this._mountModule) 
            {
                this.initView();
            }
            return this._mountModule;
        }

        public /* override */ get view(): IView
        {
            return this.initView();
        }

        protected /* override */ initView(): IView
        {
            if (null == this._mountModule) 
            {
                this._mountModule = new MountModule();
                this._mountModule.addEventListener(WindowEvent.SHOW, this.onMountWindowShow);
                this._mountModule.addEventListener(WindowEvent.CLOSE, this.onMountWindowClose);
            }
            return this._mountModule;
        }

        /* internal  */onMountWindowShow(arg1: WindowEvent): void
        {
            return;
        }

        /* internal  */onMountWindowClose(arg1: WindowEvent): void
        {
            return;
        }

        /* internal  */onCallMountsReq(arg1: DataEvent): void
        {
            var event: DataEvent;

            var loc1;
            event = arg1;
            if (RolePlayer.instance.isDoubleRest) 
            {
                ScreenOperation.interruptDoubleRest((): void
                {
                    onMountsCalling(event.data as ItemData);
                    return;
                })
                return;
            }
            this.onMountsCalling(event.data as ItemData);
            return;
        }

        /* internal  */onMountsCalling(arg1: ItemData): void
        {
            if (arg1 == null) 
            {
                return;
            }
            if (cache.status.currentStatus == StatusType.AutoFight) 
            {
                MsgManager.showRollTipsMsg(Language.getString(20340));
                return;
            }
            if (RolePlayer.instance.fighting) 
            {
                MsgManager.showRollTipsMsg(Language.getString(20341));
                return;
            }
            if (arg1.itemInfo.item.level > cache.role.entityInfo.level) 
            {
                MsgManager.showRollTipsMsg(Language.getString(20342));
                return;
            }
            if (cache.guide.transportIng) 
            {
                MsgManager.showRollTipsMsg(Language.getString(20343));
                return;
            }
            cache.pack.mountsPackCache.callingMount = arg1;
            if (arg1.itemInfo.extend.costTime != 0) 
            {
                SkillProgress.instance.updateData(ProcessType.Mounts, Language.getString(20344), arg1.itemInfo.extend.costTime, this.onMountsCallEnd);
            }
            else 
            {
                this.onMountsCallEnd();
            }
            RolePlayer.instance.addEventListener(RolePlayerEvent.ControlStateChange, this.onMountCallInterruptHander);
            return;
        }

        /* internal  */onMountsCallEnd(): void
        {
            RolePlayer.instance.removeEventListener(RolePlayerEvent.ControlStateChange, this.onMountCallInterruptHander);
            if (cache.pack.mountsPackCache.callingMount != null) 
            {
                GameProxy.mountsProxy.call(cache.pack.mountsPackCache.callingMount.uid);
            }
            cache.pack.mountsPackCache.callingMount = null;
            return;
        }

        /* internal  */onUnCallMounts(arg1: DataEvent): void
        {
            if (RolePlayer.instance.isInVideo) 
            {
                return;
            }
            var loc1=arg1.data as ItemData;
            if (loc1) 
            {
                GameProxy.mountsProxy.unCall(loc1.uid);
            }
            else 
            {
                loc1 = Cache.instance.pack.mountsPackCache.callEdMount;
                if (loc1) 
                {
                    GameProxy.mountsProxy.unCall(loc1.uid);
                }
                else if (SkillProgress.instance.running && SkillProgress.instance.type == ProcessType.Mounts) 
                {
                    SkillProgress.instance.dispose();
                }
            }
            return;
        }

        /* internal  */onMountsUnEquipReq(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            if (loc1 != null) 
            {
                GameProxy.mountsProxy.unEquip(loc1.uid);
            }
            return;
        }

        /* internal  */onMountsEquipReq(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            if (loc1 != null) 
            {
                GameProxy.mountsProxy.equip(loc1.uid);
            }
            return;
        }

        /* internal  */onMountsDelReq(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            if (loc1 != null) 
            {
                GameProxy.mountsProxy.remove(loc1.uid);
            }
            return;
        }

        /* internal  */onKeyControllCallMounts(arg1: DataEvent): void
        {
            var evt: DataEvent;

            var loc1;
            evt = arg1;
            if (RolePlayer.instance.isDoubleRest) 
            {
                ScreenOperation.interruptDoubleRest((): void
                {
                    callMounts();
                    return;
                })
                return;
            }
            this.callMounts();
            return;
        }

        /* internal  */callMounts(): void
        {
            if (RolePlayer.instance.isInVideo) 
            {
                return;
            }
            var loc1=Cache.instance.pack.mountsPackCache.equipEdMount;
            if (!loc1) 
            {
                if (cache.role.entityInfo.level >= 14) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(20345));
                }
                return;
            }
            var loc2=Cache.instance.pack.mountsPackCache.callEdMount;
            if (loc2 != null) 
            {
                if (loc2 != null) 
                {
                    GameProxy.mountsProxy.unCall(loc1.uid);
                }
            }
            else 
            {
                if (cache.battle.isInBattle) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(20346));
                    return;
                }
                this.onMountsCalling(loc1);
            }
            return;
        }

        protected onMountsDataHandler(arg1: Array<any>): void
        {
            this.updateView(arg1);
            return;
        }

        /* internal  */onMountsAddRes(arg1: ItemData): void
        {
            this.updateView(cache.pack.mountsPackCache.getAllItems());
            return;
        }

        /* internal  */onMountsDelRes(arg1: ItemData): void
        {
            this.updateView(cache.pack.mountsPackCache.getAllItems());
            return;
        }

        /* internal  */onMountsEquipRes(arg1: ItemData): void
        {
            this.updateView(cache.pack.mountsPackCache.getAllItems());
            return;
        }

        /* internal  */onMountsUnEquipRes(arg1: ItemData): void
        {
            this.updateView(cache.pack.mountsPackCache.getAllItems());
            return;
        }

        /* internal  */onMountsCallRes(arg1: ItemData): void
        {
            this.updateView(cache.pack.mountsPackCache.getAllItems());
            return;
        }

        /* internal  */onMountsUnCallRes(arg1: ItemData): void
        {
            this.updateView(cache.pack.mountsPackCache.getAllItems());
            return;
        }

        /* internal  */onMountsSaleRes(arg1: ItemData): void
        {
            this.updateView(cache.pack.mountsPackCache.getAllItems());
            return;
        }

        /* internal  */updateView(arg1: Array<any>): void
        {
            this.view.update(arg1);
            return;
        }

        /* internal  */onWindowShow(arg1: WindowEvent): void
        {
            _view.removeEventListener(WindowEvent.SHOW, this.onWindowShow);
            _view.update(cache.pack.mountsPackCache.getAllItems());
            return;
        }

        /* internal  */onMountCallInterruptHander(arg1: Object /* flash.events.Event */): void
        {
            var loc1=false;
            if (cache.pack.mountsPackCache.callingMount) 
            {
                loc1 = arg1 is RolePlayerEvent;
                if (!loc1 || !Game.scene.rolePlayer.isCanControlReleaseMagic) 
                {
                    if (SkillProgress.instance.running && SkillProgress.instance.type == ProcessType.Mounts) 
                    {
                        SkillProgress.instance.dispose();
                        MsgManager.showRollTipsMsg(Language.getString(20347));
                        cache.pack.mountsPackCache.callingMount = null;
                    }
                }
            }
            RolePlayer.instance.removeEventListener(RolePlayerEvent.ControlStateChange, this.onMountCallInterruptHander);
            return;
        }

        protected /* override */ initServer(): void
        {
            super.initServer();
            Dispatcher.addEventListener(EventName.MountButtonSkipToTabBar, this.onMountButtonToTabBar);
            NetDispatcher.addCmdListener(ServerCommand.MountsListRes, this.onMountsDataHandler);
            NetDispatcher.addCmdListener(ServerCommand.MountsAddRes, this.onMountsAddRes);
            NetDispatcher.addCmdListener(ServerCommand.MountsDelRes, this.onMountsDelRes);
            NetDispatcher.addCmdListener(ServerCommand.MountsUnCallRes, this.onMountsUnCallRes);
            NetDispatcher.addCmdListener(ServerCommand.MountsEquipRes, this.onMountsEquipRes);
            NetDispatcher.addCmdListener(ServerCommand.MountsUnEquipRes, this.onMountsUnEquipRes);
            NetDispatcher.addCmdListener(ServerCommand.MountsSaleRes, this.onMountsSaleRes);
            Dispatcher.addEventListener(EventName.CallMounts, this.onCallMountsReq);
            Dispatcher.addEventListener(EventName.MountsUnEquipReq, this.onMountsUnEquipReq);
            Dispatcher.addEventListener(EventName.MountsEquipReq, this.onMountsEquipReq);
            Dispatcher.addEventListener(EventName.MountsDelReq, this.onMountsDelReq);
            Dispatcher.addEventListener(EventName.KeyControllMounts, this.onKeyControllCallMounts, false, 0, true);
            Dispatcher.addEventListener(EventName.UnCallMounts, this.onUnCallMounts, false, 0, true);
            Dispatcher.addEventListener(EventName.MountShowModule, this.onOpenMountMudle);
            NetDispatcher.addCmdListener(ServerCommand.BackPackItemsChange, this.onBackPackChangeHandler);
            NetDispatcher.addCmdListener(ServerCommand.BackpackDataChange, this.onBackPackChangeHandler);
            NetDispatcher.addCmdListener(ServerCommand.StonepackDataChange, this.onBackPackChangeHandler);
            NetDispatcher.addCmdListener(ServerCommand.StonepackItemsChange, this.onBackPackChangeHandler);
            NetDispatcher.addCmdListener(ServerCommand.RolePackItemsChange, this.onRolePackItemsChangeHandler);
            NetDispatcher.addCmdListener(ServerCommand.RolepackDataChange, this.onRolePackItemsChangeHandler);
            NetDispatcher.addCmdListener(ServerCommand.MoneyUpdate, this.onBackPackChangeHandler);
            Dispatcher.addEventListener(EventName.MountPutOn, this.onMountPutOn);
            Dispatcher.addEventListener(EventName.MountPutOff, this.onMountPutOff);
            Dispatcher.addEventListener(EventName.MountFeedButtonClick, this.onMountFeedBtnClick);
            Dispatcher.addEventListener(EventName.MountLevelUp, this.onMountUpGradeLevel);
            Dispatcher.addEventListener(EventName.MountPutOnBindAfterSayOk, this.onChangeMountListSelectedItem);
            Dispatcher.addEventListener(EventName.MountUpGrade, this.onMountUpGrade);
            Dispatcher.addEventListener(EventName.MountSkipToHead, this.onSkipToHead);
            Dispatcher.addEventListener(EventName.MountGoExtend, this.onMountExtend);
            Dispatcher.addEventListener(EventName.MountGoWash, this.onMountWash);
            Dispatcher.addEventListener(EventName.MountGoChangeSuccess, this.onMountChangeModel);
            Dispatcher.addEventListener(EventName.MountGoWashReplace, this.onMountWashReplace);
            Dispatcher.addEventListener(EventName.MountExpDrugUse, this.onMountExpDrugUse);
            Dispatcher.addEventListener(EventName.MountShowChangeModelWindows, this.showChangeModelWindow);
            Dispatcher.addEventListener(EventName.MountHideChangeModelWindows, this.onHideChangeModelWindows);
            Dispatcher.addEventListener(EventName.MountChangeSuccess, this.onMountChangeSuccess);
            Dispatcher.addEventListener(EventName.MountOpenCraveModule, this.onOpenCraveModule);
            Dispatcher.addEventListener(EventName.MountUpdateMountCraveInfo, this.onUpdateMountCraveInfo);
            Dispatcher.addEventListener(EventName.MountGoCrave, this.onMountGoCrave);
            Dispatcher.addEventListener(EventName.MountCloseCrave, this.onMountCloseCrave);
            Dispatcher.addEventListener(EventName.MountGoRein, this.onMountGoRein);
            Dispatcher.addEventListener(EventName.MountStartsGoCulture, this.onMountStartsGoCultrue);
            Dispatcher.addEventListener(EventName.MountStartsGoCultureSuccess, this.onMountStartsGoCultureSuccess);
            Dispatcher.addEventListener(EventName.AutoGuideStepEnd, this.stepEndHandler);
            NetDispatcher.addCmdListener(ServerCommand.VIPInfoUpdateCommand, this.onVipInfoUpdate);
            Dispatcher.addEventListener(EventName.MountAdvanceGoMountAdvance, this.onMountAdvanceGoMountAdvance);
            Dispatcher.addEventListener(EventName.MountAdvanceGoMountAdvanceSuccess, this.onMountAdvanceGoMountAdvanceSuccess);
            Dispatcher.addEventListener(EventName.MountAdvanceGoFeed, this.onMountAdvanceGoFeed);
            Dispatcher.addEventListener(EventName.MountForsterTotalValueUpdate, this.onMountForsterTotalValueUpdate);
            Dispatcher.addEventListener(EventName.MountForsterFightValue, this.onMountForsterFightValue);
            Dispatcher.addEventListener(EventName.MountForsterGetFightValue, this.onMountForsterGetFightValue);
            NetDispatcher.addCmdListener(ServerCommand.ActiveMountAdvanceOneKey, this.onActiveMountAdvanceOneKey);
            NetDispatcher.addCmdListener(ServerCommand.ActiveMountAdvanceOneKeyTimes, this.onActiveMountAdvanceOneKeyTimes);
            Dispatcher.addEventListener(EventName.MountEuqipUndress, this.onMountEuqipUndress);
            Dispatcher.addEventListener(EventName.MountEquipAllUndress, this.onMountEquipAllUndress);
            Dispatcher.addEventListener(EventName.MountEquipGoUpgrade, this.onMountEquipGoUpgrade);
            NetDispatcher.addCmdListener(ServerCommand.RoleFightCombatCapabilities, this.onRoleFightCombatCapabilities);
            Dispatcher.addEventListener(EventName.MountEquipShowUpFight, this.onMountEquipShowUpFight);
            Dispatcher.addEventListener(EventName.MountEquipShowUpFightSuccess, this.onMountEquipShowUpFightSuccess);
            Dispatcher.addEventListener(EventName.MountStartsFeedOpenLv, this.onMountStartsFeedOpenLv);
            Dispatcher.addEventListener(EventName.MountStartsFeedLvOpenRelationShip, this.onMountStartsFeedLvOpenRelationShip);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicMountStarsOpen, this.onECmdPublicMountStarsOpen);
            Dispatcher.addEventListener(EventName.MountLvBackUseDrug, this.onMountLvBackUseDrug);
            return;
        }

        /* internal  */onMountLvBackUseDrug(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            var loc2=cache.pack.backPackCache.getUidListByType(ECategory._ECategoryProp, EProp._EPropMountLevelBack);
            if (MountUtil.isWearingMount()) 
            {
                if (MountUtil.isNeedMountLevelBack(Cache.instance.pack.mountsPackCache.equipEdMount.itemExInfo.mount_rein, Cache.instance.pack.mountsPackCache.equipEdMount.itemExInfo.mount_rein_l)) 
                {
                    GameProxy.mountsProxy.getMountLevelBack(Cache.instance.pack.mountsPackCache.equipEdMount.posType, Cache.instance.pack.mountsPackCache.equipEdMount.uid, loc2, 1);
                }
                else 
                {
                    MsgManager.showRollTipsMsg(Language.getString(74304));
                }
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(79018));
            }
            return;
        }

        /* internal  */onECmdPublicMountStarsOpen(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SAttribute;
            this.alertMountStartsFeedOpenLv(loc1.value, true);
            return;
        }

        /* internal  */onMountStartsFeedLvOpenRelationShip(arg1: DataEvent=null): void
        {
            var e: DataEvent=null;
            var checkFlag: Boolean;
            var mountFlag: Boolean;
            var equipMount: ItemData;
            var onClose: Function;

            var loc1;
            onClose = null;
            e = arg1;
            onClose = (arg1: int): void
            {
                if (arg1 == Alert.OK) 
                {
                    PulseSharedObject.saveValue("MountStartsFeedLvOpenRelationShip", true);
                }
                return;
            }
            checkFlag = PulseSharedObject.getValue("MountStartsFeedLvOpenRelationShip");
            mountFlag = false;
            equipMount = cache.pack.mountsPackCache.equipEdMount;
            if (equipMount && !(equipMount == ItemData.nullItemData) && equipMount.itemExInfo) 
            {
                if (equipMount.itemExInfo.m_haSt == "1") 
                {
                    mountFlag = true;
                }
            }
            if (mountFlag && !checkFlag) 
            {
                Alert.okLabel = Language.getString(69901);
                Alert.buttonWidth = 60;
                Alert.showCloseBtn = false;
                Alert.show(Language.getString(70281), null, Alert.OK, null, onClose);
            }
            return;
        }

        /* internal  */onMountStartsFeedOpenLv(arg1: DataEvent): void
        {
            this.alertMountStartsFeedOpenLv(arg1.data as int, false);
            return;
        }

        /* internal  */alertMountStartsFeedOpenLv(arg1: int, arg2: Boolean): void
        {
            var loc1=MountConfig.instance.getMountStarts(arg1);
            var loc2=Math.floor(loc1.openLevel / 1000);
            arg1 = CutDataUtil.getUnitNum(loc1.openLevel);
            if (arg1 == 0) 
            {
                arg1 = CutDataUtil.getTenNum(loc1.openLevel);
            }
            Alert.okLabel = Language.getString(69901);
            Alert.buttonWidth = 60;
            Alert.showCloseBtn = true;
            if (arg2) 
            {
                Alert.show(Language.getStringByParam(70282, loc2, arg1, loc1.name), null, Alert.OK, null);
            }
            else 
            {
                Alert.show(Language.getStringByParam(70280, loc2, arg1, loc1.name), null, Alert.OK, null);
            }
            return;
        }

        /* internal  */onRoleFightCombatCapabilities(arg1: string): void
        {
            if (this._mountModule && !this._mountModule.isHide) 
            {
                this.mountModule.updateFightUp(parseInt(arg1), true);
            }
            return;
        }

        /* internal  */onMountEquipGoUpgrade(arg1: DataEvent): void
        {
            var loc1=arg1.data.posType;
            var loc2=arg1.data.equipUid;
            var loc3=arg1.data.materials;
            var loc4=!arg1.data.isCur;
            GameProxy.equipmentProxy.mountEquipUpgrade(loc1, loc2, loc4, loc3);
            return;
        }

        /* internal  */onMountEuqipUndress(arg1: DataEvent): void
        {
            var loc1=Cache.instance.pack.rolePackCache.getIndexByUid(arg1.data.uid);
            GameProxy.roleProxy.undress_async(arg1.data.uid, loc1);
            return;
        }

        /* internal  */onMountEquipAllUndress(arg1: DataEvent): void
        {
            var loc2=null;
            var loc3=0;
            var loc1=cache.pack.mountsPackCache.getMyMountEquip();
            var loc4=0;
            while (loc4 < loc1.length) 
            {
                loc2 = loc1[loc4];
                if (loc2 && !(loc2 == ItemData.nullItemData)) 
                {
                    loc3 = Cache.instance.pack.rolePackCache.getIndexByUid(loc2.uid);
                    GameProxy.roleProxy.undress_async(loc2.uid, loc3);
                }
                ++loc4;
            }
            return;
        }

        /* internal  */onActiveMountAdvanceOneKey(arg1: Object=null): void
        {
            var loc1=arg1 as SActiveToClient;
            var loc2=loc1.modulus;
            var loc3;
            if ((loc3 = JSONHelper.deserialize(loc2)) == null) 
            {
                return;
            }
            if (loc3.hasOwnProperty("cost")) 
            {
                cache.pack.mountsPackCache.mountUpgradeActiveInfo.cost = loc3["cost"];
            }
            if (loc3.hasOwnProperty("times")) 
            {
                cache.pack.mountsPackCache.mountUpgradeActiveInfo.times = loc3["times"];
            }
            if (loc3.hasOwnProperty("value")) 
            {
                cache.pack.mountsPackCache.mountUpgradeActiveInfo.value = loc3["value"];
            }
            if (this._mountModule && !this._mountModule.isHide) 
            {
                this._mountModule.updateActiveBtn();
            }
            return;
        }

        /* internal  */onActiveMountAdvanceOneKeyTimes(arg1: Object=null): void
        {
            if (this._mountModule && !this._mountModule.isHide) 
            {
                this._mountModule.updateActiveBtn();
            }
            return;
        }

        /* internal  */onMountEquipShowUpFight(arg1: DataEvent): void
        {
            var loc6=0;
            var loc8=0;
            var loc1=arg1.data.curArr;
            var loc2=arg1.data.nextArr;
            var loc3=new Map<any, any> /* flash.utils.Dictionary */();
            var loc4=new Map<any, any> /* flash.utils.Dictionary */();
            var loc5=new Map<any, any> /* flash.utils.Dictionary */();
            var loc7=0;
            while (loc7 < loc1.length) 
            {
                loc6 = (loc3 = loc1[loc7] as Map<any, any> /* flash.utils.Dictionary */)["type"];
                loc8 = 0;
                while (loc8 < loc2.length) 
                {
                    loc4 = loc2[loc8] as Map<any, any> /* flash.utils.Dictionary */;
                    if (loc3["type"] == loc4["type"]) 
                    {
                        loc5[loc6] = loc4["value"] - loc3["value"];
                    }
                    ++loc8;
                }
                ++loc7;
            }
            GameProxy.roleProxy.calCombatCapabilitiesDif(loc5, this.onMountEquipShowUpFightSuccess, null);
            return;
        }

        /* internal  */onMountEquipShowUpFightSuccess(arg1: int, arg2: Object=null): void
        {
            if (this.mountModule && !this.mountModule.isHide) 
            {
                this.mountModule.updateFightUp(arg1, false);
            }
            return;
        }

        /* internal  */onMountForsterGetFightValue(arg1: DataEvent): void
        {
            var loc2=false;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            var loc6=null;
            var loc1=arg1.data as ItemData;
            if (loc1 && !(loc1.itemExInfo.m_was_new == "")) 
            {
                loc2 = Cache.instance.role.isPhysicalCareer;
                loc3 = MountUtil.getFosterAttrArray(loc1, loc2, false);
                loc4 = MountUtil.getFosterAttrArray(loc1, loc2, true);
                loc5 = CalcUtil.getMutiArray(loc3, loc4);
                loc6 = new Map<any, any> /* flash.utils.Dictionary */();
                if (loc2) 
                {
                    loc6[3] = loc5[0];
                    loc6[4] = loc5[1];
                    loc6[5] = loc5[2];
                }
                else 
                {
                    loc6[6] = loc5[0];
                    loc6[7] = loc5[1];
                    loc6[5] = loc5[2];
                }
                cache.pack.mountsPackCache.markGetMountForsterGetFightValueFlag = true;
                GameProxy.roleProxy.calCombatCapabilitiesDif(loc6, this.showFightValue, loc1);
            }
            return;
        }

        /* internal  */showFightValue(arg1: int, arg2: ItemData): void
        {
            var loc1=null;
            if (this.mountModule && !this.mountModule.isHide) 
            {
                this.mountModule.updateForsterFightValue(arg1);
                loc1 = Cache.instance.pack.mountsPackCache.mountItemdata;
                if (loc1 && loc1.uid == arg2.uid) 
                {
                    loc1.itemExInfo.m_was_combat_dif = arg1;
                    this.onBackPackChangeHandler(null);
                }
            }
            cache.pack.mountsPackCache.markGetMountForsterGetFightValueFlag = false;
            return;
        }

        /* internal  */onMountForsterFightValue(arg1: DataEvent): void
        {
            if (this.mountModule && !this.mountModule.isHide) 
            {
                this.mountModule.updateForsterFightValue(arg1.data as int);
            }
            return;
        }

        /* internal  */onMountForsterTotalValueUpdate(arg1: DataEvent): void
        {
            var loc1=arg1.data as SMountWash;
            if (this.mountModule && !this.mountModule.isHide) 
            {
                this.mountModule.updateForsterTotalValue(loc1);
            }
            return;
        }

        /* internal  */onMountAdvanceGoFeed(arg1: DataEvent): void
        {
            var loc1=arg1.data.posType;
            var loc2=arg1.data.count;
            var loc3=arg1.data.mountUid;
            var loc4=arg1.data.materials;
            var loc5=arg1.data.useAll;
            GameProxy.mountsProxy.mountAdvanceFeed(loc1, loc3, loc4, loc2, loc5);
            return;
        }

        /* internal  */onMountAdvanceGoMountAdvance(arg1: DataEvent): void
        {
            var loc1=arg1.data.posType;
            var loc2=arg1.data.count;
            var loc3=arg1.data.mountUid;
            var loc4=arg1.data.activeOneKey;
            GameProxy.mountsProxy.mountAdvance(loc1, loc3, loc2, loc4);
            return;
        }

        /* internal  */onMountAdvanceGoMountAdvanceSuccess(arg1: DataEvent): void
        {
            return;
        }

        /* internal  */onVipInfoUpdate(arg1: Object=null): void
        {
            if (cache.vip.vipInfo) 
            {
                if (isViewShow) 
                {
                    this.mountModule.updateMountUpgradeVip();
                }
            }
            return;
        }

        /* internal  */stepEndHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as AutoGuideData;
            if (loc1.mainId == 4 && loc1.stepId == 2) 
            {
                MsgManager.showTaskTarget(Language.getString(70262), 4);
            }
            return;
        }

        /* internal  */onMountStartsGoCultureSuccess(arg1: DataEvent): void
        {
            var loc1=arg1.data.level;
            var loc2=arg1.data.uid;
            var loc3=arg1.data.result;
            var loc4=arg1.data.materialAmount;
            var loc5=arg1.data.gold;
            var loc6=arg1.data.coinBind;
            var loc7=arg1.data.needOpenNextStars;
            var loc8=arg1.data.isSingle;
            var loc9=arg1.data.resultAttAndColor;
            this._mountModule.updateMountStartsResult(loc1, loc2, loc3, loc4, loc5, loc6, loc7, loc8, loc9);
            return;
        }

        /* internal  */onMountStartsGoCultrue(arg1: DataEvent): void
        {
            var loc1=arg1.data.lv;
            var loc2=arg1.data.posType;
            var loc3=arg1.data.uid;
            var loc4=arg1.data.autoBuy;
            var loc5=arg1.data.isSingle;
            var loc6=arg1.data.useBind;
            GameProxy.mountsProxy.mountStarsCulture(loc1, loc2, loc3, loc4, loc5, loc6);
            return;
        }

        /* internal  */onOpenMountMudle(arg1: DataEvent): void
        {
            var loc1=null;
            var loc2=null;
            if (this.mountModule.isHide) 
            {
                loc1 = Cache.instance.pack.mountsPackCache.getMountArrayFromPack();
                loc2 = Cache.instance.pack.mountsPackCache.getItemMountCanFeed();
                this.mountModule.updateListPanel(loc1);
                this.mountModule.updateItemFeed(loc2);
                this.mountModule.updateReinDrug();
                this.mountModule.show();
            }
            else 
            {
                this.mountModule.hide();
            }
            return;
        }

        /* internal  */onMountCloseCrave(arg1: DataEvent): void
        {
            if (this._craveWindow && !this._craveWindow.isHide) 
            {
                this._craveWindow.hide();
            }
            return;
        }

        /* internal  */onMountGoRein(arg1: DataEvent): void
        {
            var loc1=(arg1.data.mountData as ItemData).posType;
            var loc2=arg1.data.mountData;
            var loc3=arg1.data.autoBuy;
            var loc4=arg1.data.useBind;
            GameProxy.mountsProxy.mountReincarnate(loc1, loc2, loc3, loc4);
            return;
        }

        /* internal  */onMountGoCrave(arg1: DataEvent): void
        {
            var loc1=arg1.data.itemData as ItemData;
            var loc2=arg1.data.content as string;
            var loc3=arg1.data.fontColor as int;
            var loc4=arg1.data.lightColor as int;
            GameProxy.mountsProxy.markInscriptions(loc1.posType, loc1.uid, loc2, loc3, loc4);
            return;
        }

        /* internal  */onUpdateMountCraveInfo(arg1: DataEvent): void
        {
            if (this._craveWindow && !this._craveWindow.isHide) 
            {
                if (MountConfig.instance.isCanCrave(arg1.data as ItemData)) 
                {
                    this._craveWindow.setData(arg1.data as ItemData);
                }
                else 
                {
                    MsgManager.showRollTipsMsg(Language.getString(70178));
                }
            }
            return;
        }

        /* internal  */onMountChangeSuccess(arg1: DataEvent): void
        {
            if (this._changeModelWindow) 
            {
                this._changeModelWindow.hide();
            }
            return;
        }

        /* internal  */onHideChangeModelWindows(arg1: DataEvent): void
        {
            if (this._changeModelWindow) 
            {
                this._changeModelWindow.hide();
            }
            return;
        }

        /* internal  */showChangeModelWindow(arg1: DataEvent): void
        {
            if (this._changeModelWindow == null) 
            {
                this._changeModelWindow = new MountChangeModelWindow();
            }
            this._changeModelWindow.setData(arg1.data as ItemData);
            this._changeModelWindow.show();
            return;
        }

        /* internal  */onOpenCraveModule(arg1: DataEvent): void
        {
            if (this._craveWindow == null) 
            {
                this._craveWindow = new MountCraveWindow();
            }
            this._craveWindow.setData(arg1.data as ItemData);
            this._craveWindow.show();
            return;
        }

        /* internal  */onSkipToHead(arg1: DataEvent): void
        {
            if (this._mountModule) 
            {
                this._mountModule.setCurMountListSelectedIndex(0);
            }
            return;
        }

        /* internal  */onMountExpDrugUse(arg1: DataEvent): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=null;
            var loc4=0;
            var loc5=null;
            var loc6=null;
            var loc7=0;
            var loc8=NaN;
            var loc9=0;
            var loc10=0;
            var loc11=0;
            var loc12=0;
            var loc13=false;
            var loc14=NaN;
            var loc15=0;
            var loc16=false;
            var loc17=false;
            var loc18=false;
            if (arg1.data) 
            {
                this.amount = arg1.data["amount"];
                this._mountExpDrug = arg1.data["itemData"];
                if (cache.pack.mountsPackCache.equipEdMount) 
                {
                    loc3 = cache.pack.mountsPackCache.equipEdMount;
                    loc4 = ItemConfig.instance.getInfoByCode(this._mountExpDrug.itemCode).item.effectEx;
                    loc5 = DateParser.strToDateNormal(loc3.itemExInfo.l_feed_dt);
                    loc6 = ClockManager.instance.nowDate;
                    if (!(loc5.getMonth() === loc6.getMonth()) || !(loc5.getFullYear() === loc6.getFullYear()) || !(loc5.getDate() === loc6.getDate())) 
                    {
                        loc1 = 0;
                    }
                    else 
                    {
                        loc1 = loc3.itemExInfo.feed_degree;
                    }
                    loc2 = loc4 * this.amount;
                    if (loc3.itemExInfo) 
                    {
                        if (loc1 < 100) 
                        {
                            loc8 = 0;
                            loc9 = loc3.itemExInfo.mount_level;
                            loc10 = loc3.itemExInfo.experience;
                            loc11 = loc2;
                            loc13 = false;
                            while (loc11 > 0) 
                            {
                                loc14 = MountConfig.instance.getTotalExpByLevel(loc9 + loc3.itemExInfo.mount_rein * 1000);
                                if (loc11 > loc14) 
                                {
                                    loc7 = loc14;
                                }
                                else 
                                {
                                    loc7 = loc11;
                                }
                                loc15 = MountConfig.instance.getExpPerDegree(loc9 + loc3.itemExInfo.mount_rein * 1000);
                                loc8 = loc8 + loc7 / loc15;
                                loc11 = loc11 - loc7;
                                if (loc8 + loc1 >= 100 && !loc13) 
                                {
                                    loc13 = true;
                                    loc12 = loc2 - loc11;
                                }
                                ++loc9;
                                if (!(loc9 > 100)) 
                                {
                                    continue;
                                }
                                break;
                            }
                            if (loc8 + loc1 >= 100) 
                            {
                                if (loc16 = !PulseSharedObject.isTodayNotTips("full100")) 
                                {
                                    Alert.alertWinRenderer = CheckBoxWin;
                                    Alert.show(Language.getStringByParam(70071, loc12), null, Alert.OK | Alert.CANCEL, null, this.onBtnClickHandlerI);
                                }
                                else 
                                {
                                    GameProxy.packProxy.useItem(this._mountExpDrug.uid, this.amount);
                                }
                            }
                            else 
                            {
                                GameProxy.packProxy.useItem(this._mountExpDrug.uid, this.amount);
                            }
                        }
                        else if (loc1 >= 100 && loc1 <= 119) 
                        {
                            if (loc17 = !PulseSharedObject.isTodayNotTips("full100119")) 
                            {
                                Alert.alertWinRenderer = CheckBoxWin;
                                Alert.show(Language.getString(70072), null, Alert.OK | Alert.CANCEL, null, this.onBtnClickHandlerII);
                            }
                            else 
                            {
                                GameProxy.packProxy.useItem(this._mountExpDrug.uid, this.amount);
                            }
                        }
                        else if (loc1 == 120) 
                        {
                            if (loc18 = !PulseSharedObject.isTodayNotTips("full120")) 
                            {
                                Alert.alertWinRenderer = CheckBoxWin;
                                Alert.show(Language.getString(70073), null, Alert.OK | Alert.CANCEL, null, this.onBtnClickHandlerIII);
                            }
                            else 
                            {
                                GameProxy.packProxy.useItem(this._mountExpDrug.uid, this.amount);
                            }
                        }
                    }
                }
                else 
                {
                    MsgManager.showRollTipsMsg(Language.getString(70157));
                }
            }
            return;
        }

        /* internal  */onBtnClickHandlerI(arg1: int, arg2: Boolean): void
        {
            if (arg1 == Alert.OK) 
            {
                Alert.resetToDefault();
                GameProxy.packProxy.useItem(this._mountExpDrug.uid, this.amount);
            }
            if (arg2) 
            {
                PulseSharedObject.save("full100", true);
            }
            return;
        }

        /* internal  */onBtnClickHandlerII(arg1: int, arg2: Boolean): void
        {
            if (arg1 == Alert.OK) 
            {
                Alert.resetToDefault();
                GameProxy.packProxy.useItem(this._mountExpDrug.uid, this.amount);
            }
            if (arg2) 
            {
                PulseSharedObject.save("full100119", true);
            }
            return;
        }

        /* internal  */onBtnClickHandlerIII(arg1: int, arg2: Boolean): void
        {
            if (arg1 == Alert.OK) 
            {
                Alert.resetToDefault();
                GameProxy.packProxy.useItem(this._mountExpDrug.uid, this.amount);
            }
            if (arg2) 
            {
                PulseSharedObject.save("full120", true);
            }
            return;
        }

        /* internal  */onMountWashReplace(arg1: DataEvent): void
        {
            var loc1=null;
            if (arg1.data) 
            {
                loc1 = arg1.data as ItemData;
                GameProxy.mountsProxy.replaceMountGrow(loc1.posType, loc1.uid);
            }
            return;
        }

        /* internal  */onMountChangeModel(arg1: DataEvent): void
        {
            var loc1=arg1.data;
            var loc2=loc1.posType;
            var loc3=loc1.mountUid;
            var loc4=loc1.modelId;
            GameProxy.mountsProxy.mountChangeModel(loc2, loc3, loc4);
            return;
        }

        /* internal  */onMountWash(arg1: DataEvent): void
        {
            var loc1=arg1.data;
            var loc2=loc1.posType;
            var loc3=loc1.mountUid;
            var loc4=loc1.materials;
            var loc5=loc1.autoBuy;
            var loc6=1;
            if (!(loc1.count == null) && loc1.count > 1) 
            {
                loc6 = loc1.count;
            }
            GameProxy.mountsProxy.refreshMountGrow(loc2, loc3, loc6, loc4, loc5);
            return;
        }

        /* internal  */onMountExtend(arg1: DataEvent): void
        {
            var loc1=arg1.data;
            var loc2=loc1.main;
            var loc3=loc1.deputy;
            var loc4=loc1.growthSelect;
            GameProxy.mountsProxy.mountMerge(loc2, loc3, loc4);
            return;
        }

        /* internal  */onMountButtonToTabBar(arg1: DataEvent): void
        {
            var loc1=arg1.data as int;
            if (this.view.isHide) 
            {
                this.view.show();
            }
            this._mountModule.showToTab(loc1);
            return;
        }

        /* internal  */onMountUpGrade(arg1: DataEvent): void
        {
            var loc1=null;
            if (this._mountModule) 
            {
                loc1 = arg1.data;
                GameProxy.equipmentProxy.equipUpdate(loc1.operationId, loc1.posType, loc1.mountUid, loc1.materials, loc1.topAddition, loc1.flag, false, loc1.targetType, loc1.autoBuy);
            }
            return;
        }

        /* internal  */onRolePackItemsChangeHandler(arg1: Object=null): void
        {
            var loc1=0;
            var loc2=null;
            var loc3=0;
            var loc4=0;
            if (this._mountModule) 
            {
                loc2 = Cache.instance.pack.mountsPackCache.getMountArrayFromPack();
                this._mountModule.updateListPanel(loc2);
                this._mountModule.updateMountEquipShow();
                this._mountModule.updateEquipList();
            }
            if (cache.pack.mountsPackCache.equipEdMount && !(cache.pack.mountsPackCache.equipEdMount == ItemData.nullItemData)) 
            {
                if (this.addTipIData) 
                {
                    if (this.addTipIData.uid != cache.pack.mountsPackCache.equipEdMount.uid) 
                    {
                        this.addTipIData = cache.pack.mountsPackCache.equipEdMount;
                    }
                    else 
                    {
                        loc3 = MountUtil.getAllLevelTotalExp(this.addTipIData.itemExInfo.mount_level + this.addTipIData.itemExInfo.mount_rein * 1000) + this.addTipIData.itemExInfo.experience;
                        loc1 = (loc4 = MountUtil.getAllLevelTotalExp(cache.pack.mountsPackCache.equipEdMount.itemExInfo.mount_level + cache.pack.mountsPackCache.equipEdMount.itemExInfo.mount_rein * 1000) + cache.pack.mountsPackCache.equipEdMount.itemExInfo.experience) - loc3;
                        if (loc1 > 0) 
                        {
                            MsgManager.addTipText(Language.getStringByParam(70216, loc1));
                            this.addTipIData = cache.pack.mountsPackCache.equipEdMount;
                        }
                    }
                }
                else 
                {
                    this.addTipIData = cache.pack.mountsPackCache.equipEdMount;
                }
            }
            return;
        }

        /* internal  */onChangeMountListSelectedItem(arg1: DataEvent): void
        {
            return;
        }

        /* internal  */onMountUpGradeLevel(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            var loc2=loc1.posType;
            var loc3=loc1.uid;
            GameProxy.mountsProxy.upgradeMountLevel(loc2, loc3, 1);
            return;
        }

        /* internal  */onMountFeedBtnClick(arg1: DataEvent): void
        {
            var loc6=null;
            var loc7=0;
            var loc1=arg1.data;
            var loc2=loc1.mountIData.uid;
            var loc3=loc1.mountIData.posType;
            var loc4;
            var loc5=(loc4 = loc1.items).length;
            var loc8=new Map<any, any> /* flash.utils.Dictionary */();
            var loc9=new Map<any, any> /* flash.utils.Dictionary */();
            var loc10=0;
            var loc11=0;
            var loc12=0;
            while (loc12 < loc5) 
            {
                loc6 = loc4[loc12]["itemData"] as ItemData;
                loc7 = loc4[loc12]["num"] as int;
                if (loc6.posType != EPlayerItemPosType._EPlayerItemPosTypeBag) 
                {
                    if (loc6.posType != EPlayerItemPosType._EPlayerItemPosTypeStoneBag) 
                    {
                        Log.system("坐骑喂养ERROR" + loc6.name + "~" + loc6.uid + "~" + loc6.posType);
                    }
                    else 
                    {
                        loc9[loc6.uid] = loc7;
                        ++loc11;
                    }
                }
                else 
                {
                    loc8[loc6.uid] = loc7;
                    ++loc10;
                }
                ++loc12;
            }
            if (loc10 > 0) 
            {
                GameProxy.mountsProxy.feedMount(loc3, loc2, EPlayerItemPosType._EPlayerItemPosTypeBag, loc8);
            }
            if (loc11 > 0) 
            {
                GameProxy.mountsProxy.feedMount(loc3, loc2, EPlayerItemPosType._EPlayerItemPosTypeStoneBag, loc9);
            }
            return;
        }

        /* internal  */onMountPutOff(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            if (loc1 && loc1.category == ECategory._ECategoryMount) 
            {
                GameController.player.unDress(loc1.uid);
            }
            return;
        }

        /* internal  */onMountPutOn(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            if (loc1 && loc1.category == ECategory._ECategoryMount) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_EquipMount, loc1));
            }
            return;
        }

        private /* var */_mountModule: IMountModule;

        private /* var */addTipIData: ItemData;

        private /* var */_changeModelWindow: MountChangeModelWindow;

        private /* var */amount: int;

        private /* var */_craveWindow: MountCraveWindow;

        private /* var */_mountExpDrug: ItemData;
    }
